package third_exp;

public class exp_2 {
    public static void main(String[] args)
    {
        BankOfXian box = new BankOfXian(5.201, 0.016, 10000);
        BankOfChangan boc = new BankOfChangan(5.201, 0.011, 10000);
        System.out.println(box.computeInterest() - boc.computeInterest());
    }
}

class Bank
{
    private int year;
    private double interestRate;
    private double savedMoney;

    public Bank(int year, double interestRate, double savedMoney)
    {
        this.year = year;
        this.interestRate = interestRate;
        this.savedMoney = savedMoney;
    }
    public double computeInterest()
    {
        return year * interestRate * savedMoney;
    }
    public double getInterestRate()
    {
        return interestRate;
    }
    public double getSavedMoney()
    {
        return savedMoney;
    }
}

class BankOfXian extends Bank
{
    private double year;

    public BankOfXian(double ye, double interestR, double savedMon)
    {
        super((int)ye, interestR, savedMon);
        this.year = ye;
    }
    public double computeInterest()
    {
        double interest = (int)year * super.getInterestRate() * super.getSavedMoney();
        interest += (int)(year * 1000 ) % 1000 * super.getInterestRate() * super.getSavedMoney() / 356;
        return interest;
    }
}

class BankOfChangan extends Bank
{
    private double year;

    public BankOfChangan(double ye, double interestR, double savedMon)
    {
        super((int)ye, interestR, savedMon);
        this.year = ye;
    }
    public double computeInterest()
    {
        double interest = (int)year * super.getInterestRate() * super.getSavedMoney();
        interest += (int)(year * 1000 ) % 1000 * super.getInterestRate() * super.getSavedMoney() / 356;
        return interest;
    }
}
